package StreamDemo.demo1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

public class test2 {
    public static void main(String[] args){
        // 创建一个集合
        ArrayList<String> arr = new ArrayList<>();
        Collections.addAll(arr,"aaa","bbb","ccc");
        // 获取流
        Stream<String> s = arr.stream();
        s.forEach(name -> System.out.println(name));

        HashMap<String,Integer> hs = new HashMap<>();
        // 添加元素
        hs.put("aaa", 1);
        hs.put("bbb", 2);
        hs.put("ccc", 3);
        // 获取键值对集合
        Set<Map.Entry<String,Integer>> se = hs.entrySet();
        Stream<Map.Entry<String,Integer>> st = se.stream();
        se.forEach(name -> System.out.println(name));

        // 创建数组
        int[] arr1 = {1,2,3,4,5,6};
        // 获取数组的stream流
        Arrays.stream(arr1).forEach(name -> System.out.println(name));


    }
}
